package 刷题10月.数组;
// https://leetcode-cn.com/problems/binary-search/
public class 二分查找1016 {
    class Solution {
        public int search(int[] nums, int target) {
            int left=0,mid=0,right=nums.length-1;
            while(left <= right){
                //mid=(left+right)/2;
                mid=left+(right-left)/2;
                if(nums[mid]==target){
                    return mid;
                }
                else if(nums[mid]<target){
                    left=mid+1;
                }
                else
                    right=mid-1;
            }
            return -1;
        }
    }
}
